package com.example.demo.upload;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.multipart.MaxUploadSizeExceededException;
import org.springframework.web.multipart.MultipartException;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

/**
 * Created by czc-pual on 2018/12/12.
 */
@ControllerAdvice
public class GlobalExceptionHandler {


    @ExceptionHandler(value = MaxUploadSizeExceededException.class)
    public String exceptionMuitPart(MultipartException e,RedirectAttributes redirectAttributes){
        redirectAttributes.addFlashAttribute("message",e.getCause().getMessage());
//        return "redirect:/success";
        return "redirect:/a";

    }


}
